package com.mashibing.tank;


import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Objects;

/**
 * Copyright (C) 2024 - 2024 Jasonakeke， Inc. All Rights Reserved
 *
 * @Desc :
 * @Time : 2024/10/13 22:07
 * @Author : Code_By_Jasonakeke
 * @Email : 2284037977@qq.com
 * @Class : ResourceMgr
 * @IDE : IntelliJ IDEA
 */
public class ResourceMgr {

	public static final BufferedImage goodTankL;
	public static final BufferedImage goodTankU;
	public static final BufferedImage goodTankR;
	public static final BufferedImage goodTankD;

	public static final BufferedImage badTankL;
	public static final BufferedImage badTankU;
	public static final BufferedImage badTankR;
	public static final BufferedImage badTankD;

	public static final BufferedImage bulletL;
	public static final BufferedImage bulletU;
	public static final BufferedImage bulletR;
	public static final BufferedImage bulletD;

	public static final BufferedImage[] explodes = new BufferedImage[16];

	static {
		try {
			goodTankU = ImageIO.read(Objects.requireNonNull(ResourceMgr.class.getClassLoader().getResourceAsStream("images/GoodTank1.png")));
			goodTankL = ImageUtil.rotateImage(goodTankU, -90);
			goodTankR = ImageUtil.rotateImage(goodTankU, 90);
			goodTankD = ImageUtil.rotateImage(goodTankU, 180);

			badTankU = ImageIO.read(Objects.requireNonNull(ResourceMgr.class.getClassLoader().getResourceAsStream("images/BadTank1.png")));
			badTankL = ImageUtil.rotateImage(badTankU, -90);
			badTankR = ImageUtil.rotateImage(badTankU, 90);
			badTankD = ImageUtil.rotateImage(badTankU, 180);

			bulletU = ImageIO.read(Objects.requireNonNull(ResourceMgr.class.getClassLoader().getResourceAsStream("images/bulletU.png")));
			bulletL = ImageUtil.rotateImage(bulletU, -90);
			bulletR = ImageUtil.rotateImage(bulletU, 90);
			bulletD = ImageUtil.rotateImage(bulletU, 180);

			for (int i = 0; i < explodes.length; i++) {
				explodes[i] = ImageIO.read(Objects.requireNonNull(ResourceMgr.class.getClassLoader().getResourceAsStream("images/e" + (i + 1) + ".gif")));
			}
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
}
